//
//  BK_Confirm_Order_Contact_Cell.m
//  bestkeep
//
//  Created by TOPTEAM on 2017/2/21.
//  Copyright © 2017年 utouu. All rights reserved.
//

#import "BK_Confirm_Order_Contact_Cell.h"
#import "BK_OD_Color.h"
#import "BK_OD_Tool.h"
@implementation BK_Confirm_Order_Contact_Cell
{
    UIImageView *_BGImageView;
    UIImageView *_userIcon;
    UIImageView *_phoneIcon;
    UIImageView *_rightArrow;
    UILabel     *_userName;
    UILabel     *_phoneNumber;
    UILabel     *_address;
    UILabel     *_notFindAddrdss;
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self initialize];
    }
    return self;
}

- (void)initialize{
    _BGImageView = [[UIImageView alloc] init];
    [self.contentView addSubview:_BGImageView];
    
    _userIcon = [[UIImageView alloc] init];
    [self.contentView addSubview:_userIcon];
    
    _phoneIcon = [[UIImageView alloc] init];
    [self.contentView addSubview:_phoneIcon];
    
    _rightArrow = [[UIImageView alloc] init];
    [self.contentView addSubview:_rightArrow];
    
    _userName = [[UILabel alloc] initWithFrame:CGRectZero];
    _userName.backgroundColor = [UIColor clearColor];
    _userName.textColor = kOrderBlack1;
    _userName.font = UIFontBoldCustom(15);
    _userName.numberOfLines = 1;
    [self.contentView addSubview:_userName];
    
    _phoneNumber = [[UILabel alloc] initWithFrame:CGRectZero];
    _phoneNumber.backgroundColor = [UIColor clearColor];
    _phoneNumber.textColor = kOrderBlack1;
    _phoneNumber.font = UIFontBoldCustom(15);
    _phoneNumber.numberOfLines = 1;
    [self.contentView addSubview:_phoneNumber];
    
    _address = [[UILabel alloc] initWithFrame:CGRectZero];
    _address.backgroundColor = [UIColor clearColor];
    _address.textColor = kOrderMediumGrey1;
    _address.font = UIFontCustom(14);
    _address.numberOfLines = 2;
    [self.contentView addSubview:_address];
    
    _notFindAddrdss = [[UILabel alloc] init];
    _notFindAddrdss.backgroundColor = [UIColor clearColor];
    _notFindAddrdss.textColor = kOrderMediumGrey1;
    _notFindAddrdss.font = UIFontCustom(18);
    _notFindAddrdss.hidden = YES;
    [self.contentView addSubview:_notFindAddrdss];
    
    [self makeConstrains];
}

- (void)makeConstrains{
    
    [_BGImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.left.bottom.right.mas_equalTo(self.contentView);
    }];
    
    [_userIcon mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(self.contentView).offset(ApplicationBackGauge);
        make.top.mas_equalTo(self.contentView).offset(kOrderSpacingFar);
        make.height.mas_equalTo(@18);
        make.width.mas_equalTo(@18);
    }];
    
    [_userName mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(_userIcon.mas_right).offset(8);
        make.centerY.mas_equalTo(_userIcon.mas_centerY);
        make.width.mas_equalTo(@100);
    }];
    
    [_phoneIcon mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(_userName.mas_right).offset(8);
        make.centerY.mas_equalTo(_userIcon.mas_centerY);
        make.height.mas_equalTo(@18);
        make.width.mas_equalTo(@18);
    }];
    
    [_phoneNumber mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(_phoneIcon.mas_right).offset(8);
        make.centerY.mas_equalTo(_userIcon.mas_centerY);
        make.right.mas_equalTo(self.contentView.mas_right).offset(-ApplicationBackGauge);
    }];
    
    [_rightArrow mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_equalTo(self.contentView).offset(-ApplicationBackGauge);
        make.centerY.mas_equalTo(self.contentView.mas_centerY);
        make.width.height.mas_equalTo(16);
    }];
    
    [_address mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(self.contentView.mas_left).offset(ApplicationBackGauge);
        make.top.mas_equalTo(self.contentView.mas_centerY);
        make.right.mas_equalTo(_rightArrow.mas_left).offset(-20);
    }];
    
    [_notFindAddrdss mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.mas_equalTo(self);
        make.centerY.mas_equalTo(self);
    }];
}

- (void)fillData:(id)data{
    BKOrderUsedAddress *address = data;
    _BGImageView.image = [UIImage imageNamed:@"BKOrder_address_BG"];
    if (!address.deliver_id) {
        _notFindAddrdss.hidden = NO;
        _notFindAddrdss.text = kOrderLocalizeString(@"BKOrderChooseAddress");
        _rightArrow.image = [UIImage imageNamed:@"BKOrderArrow_right"];
        return;
    }
    _notFindAddrdss.hidden = YES;
    _userName.text = address.deliver_name;
    _phoneNumber.text = address.deliver_mobile;
    _address.text = address.deliver_address;
    _userIcon.image = [UIImage imageNamed:@"BKOrder_user"];
    _phoneIcon.image = [UIImage imageNamed:@"BKOrder_phone"];
    _rightArrow.image = [UIImage imageNamed:@"BKOrderArrow_right"];
}
+ (CGFloat)computeHeight:(id)data
{
    return 100;
}

@end


